refactor: V1Trap derives from PDU, not the v2 Trap - #31
Merged
Conversation
An RFC 1157 trap is its own variant of the protocol's PDU CHOICE, not an SNMPv2 trap: inheriting Trap silently redefined #oid to mean the enterprise OID and dragged in v2 trap semantics that do not exist on the v1 wire (Liskov). - v1_trap: derive from PDU; own enterprise / time_ticks properties; #oid gets its standard PDU meaning back (first varbind). The v2-style request-id / error fields inherited from PDU stay at their defaults, documented as such - session: trap_v1 passes enterprise: (was oid:) - spec: v1_trap_spec (not-a-Trap, enterprise vs oid); snmp_spec asserts both accessors on a real captured trap; notifications_spec updated BREAKING: V1Trap#oid now returns the first varbind's OID (use #enterprise for the enterprise); V1Trap no longer is_a?(Trap). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The final audit item (#7) — previously deferred, brought forward since it is a breaking change and belongs before 1.0 (afterwards it would cost a major).
Problem
V1Trap < Trap < PDU, but an RFC 1157 trap is its own variant of the protocol's PDU CHOICE, not an SNMPv2 trap (Liskov violation):Trap#oidmeans snmpTrapOID;V1Trap#oidsilently meant the enterprise OID — same accessor, different meaning.V1Trapdragged in v2 trap semantics that do not exist on the v1 wire, and its parse constructor re-initialised every inherited field.Change
V1Trapnow derives fromPDUdirectly (a v1 Trap-PDU is a PDU — it carries varbinds and flows throughMessage— it just isn't a v2 trap). TheMessage#pduunion and all its proxies are untouched.enterprise/time_ticksproperties;#oidgets its standard PDU meaning back (first varbind's OID).PDUhave no meaning in v1 and stay at their defaults — documented as the deliberate trade-off for keeping the sharedPDUinterface.Session#trap_v1passesenterprise:(wasoid:).Warning
Breaking (pre-1.0):
V1Trap#oidnow returns the first varbind's OID — use#enterprisefor the enterprise OID;v1trap.is_a?(Trap)is now false.Tests
New
v1_trap_spec(not-a-Trap,enterprisevsoid);snmp_specasserts both accessors against a real captured trap; the v1 build→parse round-trip (notifications_spec) still passes. Deterministic 94/94, multi-threaded 94/94, legacy 3/3, ameba clean, format clean.With this merged the audit (#7) is complete: 64/64.
🤖 Generated with Claude Code